package com.it.elmboot.controller;

import com.it.elmboot.pojo.Business;
import com.it.elmboot.service.BusinessService;
import com.it.elmboot.service.impl.BusinessServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/business")
public class BusinessController {
    @Autowired
    BusinessService businessService;

    @GetMapping("/getAll")
    @ResponseBody
    public ResponseEntity<Object> getAll(){
        List<Business> all = businessService.getAll();
        return new ResponseEntity<>(all, HttpStatus.OK);
    }

    @GetMapping("/getBusinessById")
    @ResponseBody
    public ResponseEntity<Object> getBusinessById(@RequestParam Integer businessId){
        return new ResponseEntity<>(businessService.getBusinessById(businessId), HttpStatus.OK);
    }

    @GetMapping("/listBusinessByOrderTypeId")
    public List<Business> listBusinessByOrderTypeId(@RequestParam Integer orderTypeId) throws Exception{
        return businessService.listBusinessByOrderTypeId(orderTypeId);
    }

}
